package com.cyys.modules.system.dao.recycle;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.cyys.common.mapper.CyysBaseMapper;
import com.cyys.modules.system.model.recycle.SysRecycle;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
* @description 系统回收站Dao层
* @author LC
* @date 2020-10-30
*/
public interface SysRecycleDao extends CyysBaseMapper<SysRecycle> {

    List<SysRecycle> getAllTableComment() ;

    @Select("select `TABLE_NAME`,`TABLE_COMMENT` from information_schema.TABLES where TABLE_SCHEMA=(select database())")
    List<SysRecycle> listTable() ;

    /**
     * 数据恢复
     * @param id
     * @param tableName
     * @
     */
    void recovery(String id, String tableName) ;

    /**
     * 数据彻底删除
     * @param id
     * @param tableName
     * @
     */
    void deletion(String id, String tableName) ;

    /**
     * 根据表名获取表数据
     * @param page
     * @param tableName 表名
     * @param queryParams 查询参数
     * @return
     */
    List<HashMap<String, Object>> listByTableName(Page page, @Param("tableName") String tableName, @Param("queryParams") Map queryParams);

    /**
     * 查询表的所有列数据
     * @param tableName
     * @return
     * @
     */
    @Select("select COLUMN_NAME AS columnName, COLUMN_TYPE AS columnType,COLUMN_COMMENT AS columnComment from information_schema.COLUMNS where TABLE_SCHEMA = (select database()) and TABLE_NAME=#{tableName}")
    List<Map> listTableColumn(String tableName) ;
}
